package com.mk.admin.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.vo.*;
import com.mk.admin.service.PayService;
import com.mk.admin.service.WeChatPayService;
import com.mk.admin.util.HttpTool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WeChatPayServiceImpl implements WeChatPayService {
    @Autowired
    private PayService payService;

    @Override
    public ResultDto registerPay(WeChatRegisterPayVo vo) {
        JSONObject jsonObject = HttpTool.postJson("pay_0330", vo);
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto registerBack(WeChatRegisterPayBackVo vo) {
        JSONObject jsonObject = HttpTool.postJson("pay_0325", vo);
        return ResultDto.data(jsonObject);
    }

    @Override
    public ResultDto refund(WeChatRefundVo vo) {
        JSONObject jsonObject = refundJson(vo);
        return ResultDto.data(jsonObject);
    }

    public JSONObject refundJson(WeChatRefundVo vo) {
        return HttpTool.postJson("pay_0327", vo);
    }

    @Override
    public ResultDto refundSelect(WeChatRefundSelectVo vo) {
        JSONObject jsonObject = refundSelectJson(vo);
        return ResultDto.data(jsonObject);
    }

    public JSONObject refundSelectJson(WeChatRefundSelectVo vo) {
        return HttpTool.postJson("pay_0328", vo);
    }


}
